<?php
include('util/bloqueDeSeguridad.php');
include('include/Config.php');

$empresaId = empresaidSMG;

if (isset($_GET['IdEmpresa'])) {
    $empresaId = $_GET['IdEmpresa'];
}

$arrSolicitudes = "";
if (isset($_GET['arrSolicitudes'])) {
    $arrSolicitudes = $_GET['arrSolicitudes'];
}

$fechaDesde = Date('d/m/Y', strtotime("-15 days"));
$fechaHasta = Date('d/m/Y');

if (isset($_GET['fechadesde'])) {
    $fechaDesde = $_GET["fechadesde"];
}

if (isset($_GET['fechahasta'])) {
    $fechaHasta = $_GET["fechahasta"];
}


$cantSolicitudes = 0;

$arrSolicitudesFiltradas = FiltrarArrayxIdEmpresa( $arrSolicitudes, $empresaId, $cantSolicitudes);


$debug = 0;

if($debug)
{
	print_r($_GET);
	
	echo "\$cantSolicitudes==>" . $cantSolicitudes;
	echo "\$empresaId==>" . $empresaId;
	echo "\$empresaidSMG==>" . empresaidSMG;
	echo "\$empresaidMET==>" . empresaidMET;
}

$empresa = "SMG";
$empresaArchs = "Smg";

switch($empresaId)
{
	case empresaidSMG:
		$empresa = "SMG";
		$empresaArchs = "Smg";
		break;
	case empresaidMET:
		$empresa = "MetLife";
		$empresaArchs = "Met";
		break;
}

$archExportarXls = "SolicitudExportar" . $empresaArchs . "Xls.php";
$archExportarTxt = "SolicitudExportar" . $empresaArchs . "Txt.php";

$urlExportarXls = $archExportarXls . "?arrSolicitudes=" . $arrSolicitudesFiltradas;
$urlExportarTxt = $archExportarTxt . "?arrSolicitudes=" . $arrSolicitudesFiltradas;

$tituloPagina = "Exportar Archivos " . $empresa;


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title><?php echo $tituloPagina; ?></title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <script src="Content/Scripts/jquery-1.7.2.js" type="text/javascript"></script>
        <script src="Content/Scripts/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
        <script src="Content/Scripts/jquery.ui.multiselect-4.3.3.js" type="text/javascript"></script>

        <script src="js/i18n/grid.locale-es.js" type="text/javascript"></script>

        <script src="Content/Scripts/jquery.jqGrid-4.3.3.min.js" type="text/javascript"></script>
        <script src="Content/Scripts/jquery.droppy.js" type="text/javascript"></script>
        <script src="Content/Scripts/jquery.validate.min.js" type="text/javascript"></script>
        <script src="Content/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
        <script src="js/fancybox.js" type="text/javascript"></script>
        <link href="Content/Site.css" rel="stylesheet" type="text/css" />
        <link href="Content/jquery.css" rel="stylesheet" type="text/css" />
        <link href="Content/themes/redmond/jquery-ui-1.8.20.custom.css" rel="stylesheet" type="text/css" />
        <link href="Content/jqGrid/jquery-ui-jqgrid.css" rel="stylesheet" type="text/css" /> 
        <link rel="stylesheet" media="screen" type="text/css" href="Content/smoothness.datepick.css" />
        <script type="text/javascript" src="js/jquery.datepick.js"></script>
        <script type="text/javascript" src="js/jquery.datepick-es.js" ></script>
        
        <script>
        function GeneraExcel()
        {
            window.location.href = "<?php echo $urlExportarXls;?>";
         }
         
        function GeneraTxt()
        {
            window.location.href = "<?php echo $urlExportarTxt;?>";
         } 
   	function CerrarVentanaFancy()
   	{
   		window.parent.parent.location.reload();
   	}            
        </script>        
    </head>
    <body id="pop">
        <div id="main">
					<h2>Pantalla de Exportacion de Archivos de <b><?php echo $empresa;?></b></h2>
					<label name="error" id="error"></label>
	        <table class="tblalta" width="460">
	            <tr>
	                <td><br>
	                    Fecha Desde/Hasta:&nbsp;&nbsp;&nbsp;<?php echo $fechaDesde . " al " . $fechaHasta;?> <br><br>
	                    Cantidad Registros:&nbsp;&nbsp;<?php echo $cantSolicitudes . " solicitudes seleccionadas" ;?><br>
	                </td>
	            </tr>
	            <tr height="40"><td>&nbsp;</td></tr>
	            <tr>
	                <td>
	                		<?php if($cantSolicitudes > 0) { ?>
	                    <input type="button" value="Exportar <?php echo $empresa;?> TXT" id="exportarTxt" class="boton" onclick="javascript:GeneraTxt()" /> &nbsp; &nbsp; &nbsp;
	                    <input type="button" value="Exportar <?php echo $empresa;?> Excel" id="exportarExcel" class="boton" onclick="javascript:GeneraExcel()" />                
	                		<?php } else { ?>
	                		No existen solicitudes para exportar.
	                		<?php } ?>
	                </td>
	            </tr>
	            <tr height="40"><td>&nbsp;</td></tr>
	            <tr>
	                <td align="center">
	                    <input type="button" value="Cerrar Ventana" class="boton" onclick="javascript:CerrarVentanaFancy();">
	                </td>
	            </tr>  
	            </tr>
	        </table>
	      </div>
    </body>  
</html>    